<?php

$this->title = '巡检日历';
?>
<style>
    .fc-button-group, .fc button {
        display: block;
    }
    .fc-header-toolbar{
        height:100px;
    }
    .fc-event, .fc-event-dot{
        background-color: #3a87ad !important;
    }
</style>



<div id='calendar'></div>
<input type="hidden" name="personid" id="personid" value="<?= $personid ?>">




<script>


    $(document).ready(function() {

        $('#calendar').fullCalendar({
            buttonText: {
                today: '今天',
                month: '月',
                week: '周',
                day: '天'
            },
            allDayText: '全天',
            monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
            monthNamesShort: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
            dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
            dayNamesShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
            header: {
                left: 'prev,next today',
                center: 'title',
//                right: 'month,agendaWeek,agendaDay,listWeek'
                right: 'month'
            },
//            defaultDate: '2017-09-12',
            navLinks: true, // can click day/week names to navigate views
            editable: true,
            eventLimit: true, // allow "more" link when too many events
//            events: [
//                {
//                    title: '徐家旺：9:00',
//                    start: '2017-09-07',
//                },
//            ],
            events: function(start, end, timezone, callback) {
                $.ajax({
                    url: '/statistics/pig/ins-data',
                    dataType: 'json',
                    Type : 'post',
                    data: {
                        // our hypothetical feed requires UNIX timestamps
                        start: start.unix(),
                        end: end.unix(),
                        pid:$('#personid').val()
                    },
                    success: function(doc) {
                        var events = [];
//                        console.log(doc);
                        $(doc).each(function(index,v) {
                            events.push({
                                title: v.title+'已巡检',
                                start: v.start // will be parsed
                            });
                        });
                        callback(events);
                    }
                });
            },
            resources: [
                {
                    id: 'a',
                    title: 'Room A'
                },
                {
                    id: 'b',
                    title: 'Room B'
                }
            ],
//            resources: {
//                url: '/my-resource-script.php',
//                type: 'POST'
//            }
        });

    });


</script>

